package org.smi.youchu;

import cn.hutool.json.JSONUtil;
import lombok.Data;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

public class ChunkTransformer {

    private final static String filePath = "/Users/beyondsoft/Documents/01. 工作笔记/邮储/调试chunkList/格式后-01.json";

    public static void main(String[] args) {
        String original = readFile();
        List<B> formatList = JSONUtil.toList(original, B.class);
        System.out.println(JSONUtil.toJsonStr(formatList));
    }

    @Data
    class A {
        private String chunkId;
        private String context;
        private String content;
    }

    @Data
    class B {
        private String chunkId;
        private String context;
    }

    private static String readFile() {
        try {
            byte[] encoded = Files.readAllBytes(Paths.get(filePath));
            String content = new String(encoded, StandardCharsets.UTF_8);
            return content;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
}
